$OpenBSD: patch-lib-src_libnyquist_nyquist_nyqstk_src_FileRead_cpp,v 1.1 2009/10/28 18:40:13 jakemsr Exp $
--- lib-src/libnyquist/nyquist/nyqstk/src/FileRead.cpp.orig	Sat Oct 17 15:24:50 2009
+++ lib-src/libnyquist/nyquist/nyqstk/src/FileRead.cpp	Sat Oct 17 15:28:03 2009
@@ -160,7 +160,7 @@ bool FileRead :: getWavInfo( const char *fileName )
   while ( strncmp(id, "fmt ", 4) ) {
     if ( fread(&chunkSize, 4, 1, fd_) != 1 ) goto error;
 #ifndef __LITTLE_ENDIAN__
-    swap32((unsigned char *)&chunkSize);
+    NYswap32((unsigned char *)&chunkSize);
 #endif
     if ( fseek(fd_, chunkSize, SEEK_CUR) == -1 ) goto error;
     if ( fread(&id, 4, 1, fd_) != 1 ) goto error;
@@ -171,8 +171,8 @@ bool FileRead :: getWavInfo( const char *fileName )
   if ( fread(&chunkSize, 4, 1, fd_) != 1 ) goto error; // Read fmt chunk size.
   if ( fread(&format_tag, 2, 1, fd_) != 1 ) goto error;
 #ifndef __LITTLE_ENDIAN__
-  swap16((unsigned char *)&format_tag);
-  swap32((unsigned char *)&chunkSize);
+  NYswap16((unsigned char *)&format_tag);
+  NYswap32((unsigned char *)&chunkSize);
 #endif
   if ( format_tag == 0xFFFE ) { // WAVE_FORMAT_EXTENSIBLE
     dataOffset_ = ftell(fd_);
@@ -180,13 +180,13 @@ bool FileRead :: getWavInfo( const char *fileName )
     unsigned short extSize;
     if ( fread(&extSize, 2, 1, fd_) != 1 ) goto error;
 #ifndef __LITTLE_ENDIAN__
-    swap16((unsigned char *)&extSize);
+    NYswap16((unsigned char *)&extSize);
 #endif
     if ( extSize == 0 ) goto error;
     if ( fseek(fd_, 6, SEEK_CUR) == -1 ) goto error;
     if ( fread(&format_tag, 2, 1, fd_) != 1 ) goto error;
 #ifndef __LITTLE_ENDIAN__
-    swap16((unsigned char *)&format_tag);
+    NYswap16((unsigned char *)&format_tag);
 #endif
     if ( fseek(fd_, dataOffset_, SEEK_SET) == -1 ) goto error;
   }
@@ -199,7 +199,7 @@ bool FileRead :: getWavInfo( const char *fileName )
   SINT16 temp;
   if ( fread(&temp, 2, 1, fd_) != 1 ) goto error;
 #ifndef __LITTLE_ENDIAN__
-  swap16((unsigned char *)&temp);
+  NYswap16((unsigned char *)&temp);
 #endif
   channels_ = (unsigned int ) temp;
 
@@ -207,7 +207,7 @@ bool FileRead :: getWavInfo( const char *fileName )
   SINT32 srate;
   if ( fread(&srate, 4, 1, fd_) != 1 ) goto error;
 #ifndef __LITTLE_ENDIAN__
-  swap32((unsigned char *)&srate);
+  NYswap32((unsigned char *)&srate);
 #endif
   fileRate_ = (StkFloat) srate;
 
@@ -216,7 +216,7 @@ bool FileRead :: getWavInfo( const char *fileName )
   if ( fseek(fd_, 6, SEEK_CUR) == -1 ) goto error;   // Locate bits_per_sample info.
   if ( fread(&temp, 2, 1, fd_) != 1 ) goto error;
 #ifndef __LITTLE_ENDIAN__
-  swap16((unsigned char *)&temp);
+  NYswap16((unsigned char *)&temp);
 #endif
   if ( format_tag == 1 ) {
     if (temp == 8)
@@ -246,7 +246,7 @@ bool FileRead :: getWavInfo( const char *fileName )
   while ( strncmp(id, "data", 4) ) {
     if ( fread(&chunkSize, 4, 1, fd_) != 1 ) goto error;
 #ifndef __LITTLE_ENDIAN__
-    swap32((unsigned char *)&chunkSize);
+    NYswap32((unsigned char *)&chunkSize);
 #endif
     chunkSize += chunkSize % 2; // chunk sizes must be even
     if ( fseek(fd_, chunkSize, SEEK_CUR) == -1 ) goto error;
@@ -257,7 +257,7 @@ bool FileRead :: getWavInfo( const char *fileName )
   SINT32 bytes;
   if ( fread(&bytes, 4, 1, fd_) != 1 ) goto error;
 #ifndef __LITTLE_ENDIAN__
-  swap32((unsigned char *)&bytes);
+  NYswap32((unsigned char *)&bytes);
 #endif
   fileSize_ = 8 * bytes / temp / channels_;  // sample frames
 
@@ -282,7 +282,7 @@ bool FileRead :: getSndInfo( const char *fileName )
   if ( fseek(fd_, 12, SEEK_SET) == -1 ) goto error;   // Locate format
   if ( fread(&format, 4, 1, fd_) != 1 ) goto error;
 #ifdef __LITTLE_ENDIAN__
-    swap32((unsigned char *)&format);
+    NYswap32((unsigned char *)&format);
 #endif
   if (format == 2) dataType_ = STK_SINT8;
   else if (format == 3) dataType_ = STK_SINT16;
@@ -299,7 +299,7 @@ bool FileRead :: getSndInfo( const char *fileName )
   UINT32 srate;
   if ( fread(&srate, 4, 1, fd_) != 1 ) goto error;
 #ifdef __LITTLE_ENDIAN__
-  swap32((unsigned char *)&srate);
+  NYswap32((unsigned char *)&srate);
 #endif
   fileRate_ = (StkFloat) srate;
 
@@ -307,20 +307,20 @@ bool FileRead :: getSndInfo( const char *fileName )
   UINT32 chans;
   if ( fread(&chans, 4, 1, fd_) != 1 ) goto error;
 #ifdef __LITTLE_ENDIAN__
-  swap32((unsigned char *)&chans);
+  NYswap32((unsigned char *)&chans);
 #endif
   channels_ = chans;
 
   if ( fseek(fd_, 4, SEEK_SET) == -1 ) goto error;
   if ( fread(&dataOffset_, 4, 1, fd_) != 1 ) goto error;
 #ifdef __LITTLE_ENDIAN__
-  swap32((unsigned char *)&dataOffset_);
+  NYswap32((unsigned char *)&dataOffset_);
 #endif
 
   // Get length of data from the header.
   if ( fread(&fileSize_, 4, 1, fd_) != 1 ) goto error;
 #ifdef __LITTLE_ENDIAN__
-  swap32((unsigned char *)&fileSize_);
+  NYswap32((unsigned char *)&fileSize_);
 #endif
   // Convert to sample frames.
   if ( dataType_ == STK_SINT8 )
@@ -362,7 +362,7 @@ bool FileRead :: getAifInfo( const char *fileName )
   while ( strncmp(id, "COMM", 4) ) {
     if ( fread(&chunkSize, 4, 1, fd_) != 1 ) goto error;
 #ifdef __LITTLE_ENDIAN__
-    swap32((unsigned char *)&chunkSize);
+    NYswap32((unsigned char *)&chunkSize);
 #endif
     chunkSize += chunkSize % 2; // chunk sizes must be even
     if ( fseek(fd_, chunkSize, SEEK_CUR) == -1 ) goto error;
@@ -374,7 +374,7 @@ bool FileRead :: getAifInfo( const char *fileName )
   if ( fseek(fd_, 4, SEEK_CUR) == -1 ) goto error; // Jump over chunk size
   if ( fread(&temp, 2, 1, fd_) != 1 ) goto error;
 #ifdef __LITTLE_ENDIAN__
-  swap16((unsigned char *)&temp);
+  NYswap16((unsigned char *)&temp);
 #endif
   channels_ = temp;
 
@@ -382,14 +382,14 @@ bool FileRead :: getAifInfo( const char *fileName )
   SINT32 frames;
   if ( fread(&frames, 4, 1, fd_) != 1 ) goto error;
 #ifdef __LITTLE_ENDIAN__
-  swap32((unsigned char *)&frames);
+  NYswap32((unsigned char *)&frames);
 #endif
   fileSize_ = frames; // sample frames
 
   // Read the number of bits per sample.
   if ( fread(&temp, 2, 1, fd_) != 1 ) goto error;
 #ifdef __LITTLE_ENDIAN__
-  swap16((unsigned char *)&temp);
+  NYswap16((unsigned char *)&temp);
 #endif
 
   // Get file sample rate from the header.  For AIFF files, this value
@@ -402,7 +402,7 @@ bool FileRead :: getAifInfo( const char *fileName )
   if ( fread(&srate, 10, 1, fd_) != 1 ) goto error;
   mantissa = (unsigned long) *(unsigned long *)(srate+2);
 #ifdef __LITTLE_ENDIAN__
-  swap32((unsigned char *)&mantissa);
+  NYswap32((unsigned char *)&mantissa);
 #endif
   exp = 30 - *(srate+1);
   last = 0;
@@ -445,7 +445,7 @@ bool FileRead :: getAifInfo( const char *fileName )
   while ( strncmp(id, "SSND", 4) ) {
     if ( fread(&chunkSize, 4, 1, fd_) != 1 ) goto error;
 #ifdef __LITTLE_ENDIAN__
-    swap32((unsigned char *)&chunkSize);
+    NYswap32((unsigned char *)&chunkSize);
 #endif
     chunkSize += chunkSize % 2; // chunk sizes must be even
     if ( fseek(fd_, chunkSize, SEEK_CUR) == -1 ) goto error;
@@ -503,7 +503,7 @@ bool FileRead :: getMatInfo( const char *fileName )
   // Check the data element type
   SINT32 datatype;
   if ( fread(&datatype, 4, 1, fd_) != 1 ) goto error;
-  if ( byteswap_ ) swap32((unsigned char *)&datatype);
+  if ( byteswap_ ) NYswap32((unsigned char *)&datatype);
   if (datatype != 14) {
     errorString_ << "FileRead: The file does not contain a single Matlab array (or matrix) data element.";
     return false;
@@ -514,10 +514,10 @@ bool FileRead :: getMatInfo( const char *fileName )
   SINT32 size;
   if ( fseek(fd_, 168, SEEK_SET) == -1 ) goto error;
   if ( fread(&tmp, 4, 1, fd_) != 1 ) goto error;
-  if (byteswap_) swap32((unsigned char *)&tmp);
+  if (byteswap_) NYswap32((unsigned char *)&tmp);
   if (tmp == 1) {  // array name > 4 characters
     if ( fread(&tmp, 4, 1, fd_) != 1 ) goto error;  // get array name length
-    if (byteswap_) swap32((unsigned char *)&tmp);
+    if (byteswap_) NYswap32((unsigned char *)&tmp);
     size = (SINT32) ceil((float)tmp / 8);
     if ( fseek(fd_, size*8, SEEK_CUR) == -1 ) goto error;  // jump over array name
   }
@@ -525,7 +525,7 @@ bool FileRead :: getMatInfo( const char *fileName )
     if ( fseek(fd_, 4, SEEK_CUR) == -1 ) goto error;
   }
   if ( fread(&tmp, 4, 1, fd_) != 1 ) goto error;
-  if (byteswap_) swap32((unsigned char *)&tmp);
+  if (byteswap_) NYswap32((unsigned char *)&tmp);
   if ( tmp == 1 ) dataType_ = STK_SINT8;
   else if ( tmp == 3 ) dataType_ = STK_SINT16;
   else if ( tmp == 5 ) dataType_ = STK_SINT32;
@@ -540,12 +540,12 @@ bool FileRead :: getMatInfo( const char *fileName )
   SINT32 rows;
   if ( fseek(fd_, 160, SEEK_SET) == -1 ) goto error;
   if ( fread(&rows, 4, 1, fd_) != 1 ) goto error;
-  if (byteswap_) swap32((unsigned char *)&rows);
+  if (byteswap_) NYswap32((unsigned char *)&rows);
 
   // Get number of columns from the header.
   SINT32 columns;
   if ( fread(&columns, 4, 1, fd_) != 1 ) goto error;
-  if (byteswap_) swap32((unsigned char *)&columns);
+  if (byteswap_) NYswap32((unsigned char *)&columns);
 
   // Assume channels = smaller of rows or columns.
   if (rows < columns) {
@@ -561,7 +561,7 @@ bool FileRead :: getMatInfo( const char *fileName )
   SINT32 headsize;
   if ( fseek(fd_, 132, SEEK_SET) == -1 ) goto error;
   if ( fread(&headsize, 4, 1, fd_) != 1 ) goto error; // file size from 132nd byte
-  if (byteswap_) swap32((unsigned char *)&headsize);
+  if (byteswap_) NYswap32((unsigned char *)&headsize);
   headsize -= fileSize_ * 8 * channels_;
   if ( fseek(fd_, headsize, SEEK_CUR) == -1 ) goto error;
   dataOffset_ = ftell(fd_);
@@ -613,7 +613,7 @@ void FileRead :: read( StkFrames& buffer, unsigned lon
     if ( byteswap_ ) {
       SINT16 *ptr = buf;
       for ( i=nSamples-1; i>=0; i-- )
-        swap16( (unsigned char *) ptr++ );
+        NYswap16( (unsigned char *) ptr++ );
     }
     if ( doNormalize ) {
       StkFloat gain = 1.0 / 32768.0;
@@ -632,7 +632,7 @@ void FileRead :: read( StkFrames& buffer, unsigned lon
     if ( byteswap_ ) {
       SINT32 *ptr = buf;
       for ( i=nSamples-1; i>=0; i-- )
-        swap32( (unsigned char *) ptr++ );
+        NYswap32( (unsigned char *) ptr++ );
     }
     if ( doNormalize ) {
       StkFloat gain = 1.0 / 2147483648.0;
@@ -651,7 +651,7 @@ void FileRead :: read( StkFrames& buffer, unsigned lon
     if ( byteswap_ ) {
       FLOAT32 *ptr = buf;
       for ( i=nSamples-1; i>=0; i-- )
-        swap32( (unsigned char *) ptr++ );
+        NYswap32( (unsigned char *) ptr++ );
     }
     for ( i=nSamples-1; i>=0; i-- )
       buffer[i] = buf[i];
@@ -663,7 +663,7 @@ void FileRead :: read( StkFrames& buffer, unsigned lon
     if ( byteswap_ ) {
       FLOAT64 *ptr = buf;
       for ( i=nSamples-1; i>=0; i-- )
-        swap64( (unsigned char *) ptr++ );
+        NYswap64( (unsigned char *) ptr++ );
     }
     for ( i=nSamples-1; i>=0; i-- )
       buffer[i] = buf[i];
@@ -707,7 +707,7 @@ void FileRead :: read( StkFrames& buffer, unsigned lon
       if ( fread( &buf, 3, 1, fd_ ) != 1 ) goto error;
       buf >>= 8;
       if ( byteswap_ )
-        swap32( (unsigned char *) &buf );
+        NYswap32( (unsigned char *) &buf );
       if ( doNormalize )
         buffer[i] = buf * gain;
       else
